package com.cleaningcloud.cld.controller;

import com.cleaningcloud.cld.domain.CldStaffComplaint;
import com.cleaningcloud.cld.domain.CldStaffComplaintReply;
import com.cleaningcloud.cld.domain.dto.CldStaffComplaintDto;
import com.cleaningcloud.cld.domain.vo.CldStaffComplaintVo;
import com.cleaningcloud.cld.service.ICldStaffComplaintService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.web.page.TableDataInfo;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 员工投诉Controller
 *
 * @author cleaningcloud
 * @date 2024-10-27
 */
@RestController
@RequestMapping("/complaint")
public class CldStaffComplaintController extends BaseController {
    @Autowired
    private ICldStaffComplaintService cldStaffComplaintService;

    /**
     * 查询员工投诉列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CldStaffComplaintDto cldStaffComplaint) {
        startPage();
        List<CldStaffComplaintVo> list = cldStaffComplaintService.selectCldStaffComplaintList(cldStaffComplaint);
        return getDataTable(list);
    }


    /**
     * 获取员工投诉详细信息
     */
//    @RequiresPermissions("cld:staffComplaint:query")
    @GetMapping(value = "/{staffComplaintId}")
    public AjaxResult getInfo(@PathVariable("staffComplaintId") Long staffComplaintId) {
        return success(cldStaffComplaintService.selectCldStaffComplaintByStaffComplaintId(staffComplaintId));
    }

    /**
     * 新增员工投诉
     */
//    @RequiresPermissions("cld:staffComplaint:add")
    @Log(title = "员工投诉", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldStaffComplaint cldStaffComplaint) {
        return toAjax(cldStaffComplaintService.insertCldStaffComplaint(cldStaffComplaint));
    }

    /**
     * 新增员工投诉
     */
    @PostMapping("/addReply")
    public AjaxResult addReply(@RequestBody CldStaffComplaintReply cldStaffComplaintReply) {
        return toAjax(cldStaffComplaintService.addReply(cldStaffComplaintReply));
    }

    /**
     * 修改员工投诉
     */
//    @RequiresPermissions("cld:staffComplaint:edit")
    @Log(title = "员工投诉", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldStaffComplaint cldStaffComplaint) {
        return toAjax(cldStaffComplaintService.updateCldStaffComplaint(cldStaffComplaint));
    }

    /**
     * 删除员工投诉
     */
//    @RequiresPermissions("cld:staffComplaint:remove")
    @Log(title = "员工投诉", businessType = BusinessType.DELETE)
    @DeleteMapping("/{staffComplaintIds}")
    public AjaxResult remove(@PathVariable Long[] staffComplaintIds) {
        return toAjax(cldStaffComplaintService.deleteCldStaffComplaintByStaffComplaintIds(staffComplaintIds));
    }
}
